package me.uniauto.util;

import me.uniauto.mail.MailSenderInfo;
import me.uniauto.mail.SimpleMailSender;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

/**
 * Created by hardy on 2018/2/24.
 */
public enum  AppUtil {
    INSTANCE;


    //发送邮件
    public  boolean sendEmail(MailSenderInfo mailInfo){
        // 这个类主要来发送邮件
        SimpleMailSender sms = new SimpleMailSender();
        return sms.sendHtmlMail(mailInfo);// 发送html格式
    }

    /**
     * 获取本机的ip
     *
     * @return
     * @throws SocketException
     */
    public String getLocalIp() {
        String localIp = null;
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            localIp = inetAddress.getHostAddress() + " [" + inetAddress.getHostName() + "] ";
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

        return localIp;
    }

}
